from django.db import models
from django.contrib.auth.models import User # 导入用户模型

# Create your models here.


# 用户的详情模型
class UserParticulars(models.Model):
    SEX_INT = {
        (0,'女'),
        (1,'男')
    }
    avatar = models.TextField(blank=True,null=True,verbose_name='头像')  # 前后都允许为空,存的是地址
    phone = models.CharField(max_length=11,verbose_name='电话',unique=True,null=True,blank=True)
    age = models.SmallIntegerField(null=True,blank=True,verbose_name='年龄') # 整数
    sex = models.SmallIntegerField(null=True,blank=True,verbose_name='性别',choices=SEX_INT)
    birthday = models.DateField(null=True,blank=True,verbose_name='生日')

    user = models.OneToOneField(User,on_delete=models.CASCADE) # 关联字段,一对一 关联用户模型


    class Meta:
        db_table = 'UserParticulars'  # 表名
        verbose_name = '用户详情'
        verbose_name_plural = verbose_name
